package com.csi.bumblebee.service.impl;

import com.csi.bumblebee.domain.dictionary.EducationBackground;
import com.csi.bumblebee.domain.dictionary.Major;
import com.csi.bumblebee.mapper.EducationBackgroundMapper;
import com.csi.bumblebee.service.EducationBackgroundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 孙伟俊
 */
@Service
public class EducationBackgroundServiceImpl implements EducationBackgroundService {

    @Autowired
    private EducationBackgroundMapper educationBackgroundMapper;

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public EducationBackground findLevelById(String id) {
        return null;
    }

    @Override
    public List<EducationBackground> list() {

        List<EducationBackground> educationBackgroundList = (List<EducationBackground>) redisTemplate.opsForValue().get("educationBackgrounds");

        if (educationBackgroundList != null) {
            return educationBackgroundList;
        }else {
            educationBackgroundList = educationBackgroundMapper.list();
            redisTemplate.opsForValue().set("educationBackgrounds", educationBackgroundList);
            return educationBackgroundList;
        }
    }

    @Override
    public int deleteByPrimaryKey(String id) {
        return 0;
    }

    @Override
    public int insertSelective(EducationBackground educationBackground) {
        return 0;
    }

    @Override
    public int updateByPrimaryKeySelective(EducationBackground educationBackground) {
        return 0;
    }
}
